import React, { Component } from 'react';
import Child from './index_child';
import { Button, Form } from 'antd';

class Parent extends Component {
    state = {
        id: '3x273o22331',
    }

    handleSubmit = () => {
        // 子组件的form=this.ChildForm
        this.ChildForm.validateFields((err, fieldValue) => {

            // 逻辑和字段处理

            // 提交
            const { id } = this.state;
            // fieldValue.id = id;
            Object.assign(fieldValue, { id },{company:'科技有限公司'});
            console.log(fieldValue);
        });
    }

    render() {
        return (
            <div>
                <Child getForm={(m) => { this.ChildForm = m; }} />
                <Button type='primary' onClick={this.handleSubmit}>提交</Button>
            </div>
        );
    }
}

export default Parent;

